<?php
/**
 *	description:ZMAXWECHAT 消息队列模型
 *  author：min.zhang
 *  Email:zhang19min88@163.com
 *	Url:http://www.zmax99.com
 *  copyright:南宁市程序人软件科技有限责任公司保留所有权利
 *  date:2016-05-01
 * @license GNU General Public License version 3, or later
 *  check date:2016-05-26
 *  checker :min.zhang
 */

defined('_JEXEC') or die('Restricted Access');

jimport('joomla.application.component.modellist');

class zmaxwechatModelSendeds extends JModelList
{	
	public function __construct($config = array())
	{
		if(empty($config['filter_fields']))
		{
			$config['filter_fields'] = array(
			'id', 
			'title',
			'description',
			'tags'
			);
			if (JLanguageAssociations::isEnabled())
			{
				$config['filter_fields'][] = 'association';
			}
		}
		return parent::__construct($config);
	}
	
	 protected function getListQuery()
	 {
		$db = JFactory::getDBO();
		$query = $db->getQuery(true);
		$query->select('s.id AS id ,s.submit_state AS state ,s.date ,s.result,s.media_id');
		$query->from('#__zmaxwechat_sended AS s');
		$query->select('n.title AS title');
		$query->leftJoin("#__zmaxwechat_news as n ON n.media_id = s.media_id");

		$orderCol = $this->state->get("list.ordering" ,'id');
		$orderDirn = $this->state->get("list.direction",'desc');
		$query->order($db->escape($orderCol).' '.$db->escape($orderDirn));
		
		return $query;
	 }

}